package com.wyl.auth.controller;

import com.wyl.auth.service.SseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.scene.media.Media;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2025/4/22 21:32
 */
@Api(tags = "sse推送消息")
@RestController
@RequestMapping(value = "sse")
public class SseController {

    @Autowired
    private SseService sseService;

    @ApiOperation(value = "创建SSE连接")
    @GetMapping(value = "connect",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public SseEmitter connect() {
        return sseService.connect();
    }

    @ApiOperation(value = "执行定时任务")
    @GetMapping(value = "sendMessageTimer")
    public void sendMessageTimer() {
        sseService.sendMessage();
    }


}